import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [

  {
    title: '产品序号',
    align: "center",
    dataIndex: 'no',
    helpMessage: '租户编号+4位自增流水号，例子：1000-0001，1000-0002，1001-0001'
  },
  {
    title: '产品名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: 'logo',
    align: "center",
    dataIndex: 'logoList',
    width: 140,
    slots: { customRender: 'logo' },
  },

  {
    title: '分类',
    align: "center",
    dataIndex: 'category_dictText'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime',
    width: 180
  },
  {
    title: '合约地址',
    align: "center",
    dataIndex: 'contractAddress'
  },
  {
    title: '品种',
    align: "center",
    dataIndex: 'variety'
  },
  {
    title: '产地',
    align: "center",
    dataIndex: 'origin'
  },
  {
    title: '生产者',
    align: "center",
    dataIndex: 'producer'
  },
  {
    title: '生产者地址',
    align: "center",
    dataIndex: 'producerAddress'
  },
  {
    title: '品牌',
    align: "center",
    dataIndex: 'brand'
  },
  {
    title: '质量等级',
    align: "center",
    dataIndex: 'qualityGrade'
  },
  {
    title: '产品标准代码',
    align: "center",
    dataIndex: 'standardCode'
  },
  {
    title: '生产者',
    align: "center",
    dataIndex: 'producer'
  },
  {
    title: '农产品图片',
    align: "center",
    dataIndex: 'picturesList',
    width: 140,
    slots: { customRender: 'img' },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "产品名称",
    field: 'name',
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '产品名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入产品名称!' },
      ];
    },
  },

  {
    label: 'logo',
    field: 'logo',
    component: 'JImageUpload',
    componentProps: {
      bizPath: null,
      fileMax: 1,
      multiple: true
    },
  },
  {
    label: '种类',
    field: 'category',
    component: 'JTreeSelect',
    componentProps: {
      dict: "t_classification,name,id",
      pidField: "pid",
      pidValue: "1690901276535795713",
      hasChildField: "has_child",
      placeholder: '请选择种类',
    },
  },
  {
    label: '种植标准',
    field: 'standard',
    component: 'InputTextArea',
  },
  {
    label: '品种',
    field: 'variety',
    component: 'Input'
  },
  {
    label: '产地',
    field: 'origin',
    component: 'Input'
  },
  {
    label: '生产者',
    field: 'producer',
    component: 'Input'
  },
  {
    label: '生产者地址',
    field: 'producerAddress',
    component: 'Input'
  },
  {
    label: '品牌',
    field: 'brand',
    component: 'Input'
  },
  {
    label: '质量等级',
    field: 'qualityGrade',
    component: 'Input'
  },
  {
    label: '产品标准代码',
    field: 'standardCode',
    component: 'Input'
  },
  {
    label: '农产品图片',
    field: 'productImage',
    component: 'JImageUpload',
    componentProps: {
      bizPath: null,
      fileMax: 10,
      multiple: true
    },
  },
  {
    label: '产品简介',
    field: 'intro',
    component: 'JEditor',
  },
  {
    label: '宣传资料',
    field: 'introduce',
    component: 'JEditor',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'no',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
